//
//  WHRInDiagnoseCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/12/18.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "WHRInDiagnoseCell.h"



@implementation WHRInDiagnoseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
    }
    
    return self;
}

- (void)creatView {
    
    
    self.rewardBtn = [[UIButton alloc]init];
    self.rewardBtn.cornerRadius = 5;
    self.rewardBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.rewardBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [self.rewardBtn setTitleColor:COLOR_ORG forState:UIControlStateNormal];
    self.rewardBtn.borderWidth = 1;
    self.rewardBtn.borderColor = COLOR_ORG;
    [self.contentView addSubview:self.rewardBtn];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.titleLabel.font = FONT_FOURTEEN;
    self.titleLabel.textColor = COLOR_DIV;
    [self.contentView addSubview:self.titleLabel];
    
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.textAlignment = NSTextAlignmentLeft;
    self.priceLabel.font = FONT_FOURTEEN;
    self.priceLabel.textColor = COLOR_ORG;
    [self.contentView addSubview:self.priceLabel];
    
    
    self.startTimeLabel = [[UILabel alloc]init];
    self.startTimeLabel.font = FONT_FOURTEEN;
    self.startTimeLabel.textColor = COLOR_DIV;
    [self.contentView addSubview:self.startTimeLabel];
    
    
    
    self.diagnoseBtn = [[UIButton alloc]init];
    [self.diagnoseBtn addTarget:self action:@selector(shopAction:) forControlEvents:UIControlEventTouchUpInside];
    self.diagnoseBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    self.diagnoseBtn.backgroundColor = COLOR_ORG;
    [self.diagnoseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.diagnoseBtn.cornerRadius = 2;
    [self.contentView addSubview:self.diagnoseBtn];
    
    
    
    
    
    
}

- (void)setlayout {
    
    
    
    self.rewardBtn.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(60)
    .heightIs(30);
    
  
    self.diagnoseBtn.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(40)
    .heightIs(30);
    
    self.priceLabel.sd_layout
    .rightSpaceToView(self.diagnoseBtn, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(80)
    .heightIs(20);
    
    self.titleLabel.sd_layout
    .leftSpaceToView(self.rewardBtn, 10)
    .rightSpaceToView(self.priceLabel, 10)
    .topSpaceToView(self.contentView, 10)
    .heightIs(20);
    
  
    
    self.startTimeLabel.sd_layout
    .leftSpaceToView(self.rewardBtn, 10)
    .topSpaceToView(self.titleLabel, 10)
    .widthIs(SCREEN_WIDTH-90)
    .heightIs(20);
    
  
    
    [self setupAutoHeightWithBottomView:self.startTimeLabel bottomMargin:10];
    
    
}




- (void)setModel:(WHRInDiagnoseModel *)model {
    
    _model = model;
    [self.rewardBtn setTitle:_model.fFlagCHS forState:UIControlStateNormal];
    _titleLabel.text =[NSString stringWithFormat:@"作物:%@", model.fTitle];
    _priceLabel.text = [NSString stringWithFormat:@"价格:%@元",_model.fPrice];
    _startTimeLabel.text = [NSString stringWithFormat:@"咨询时间：%@",_model.fCreateTime];
    [_diagnoseBtn setTitle:_model.fStatusCHS forState:UIControlStateNormal];
  
    [self setlayout];
    
}


- (void)shopAction:(UIButton *) btn {
    
    if (self.tapCelllickedBlock) {
        
        self.tapCelllickedBlock(btn.tag);
    }
    
}



@end
